package com.ysdcrm.crm.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import com.ysdcrm.crm.mapper.ITracksMapper;
import com.ysdcrm.crm.model.Tracks;
import com.ysdcrm.crm.model.Users;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiOperation;

@RestController
@ApiOperation("跟踪信息")
@RequestMapping("track")
public class TracksController {
    @Resource
    private ITracksMapper mapper;

    @ApiOperation(value = "添加跟踪信息")
    @PostMapping
    public int add(Tracks t,HttpSession session){
        //获取登录用户id
        Users user = (Users) session.getAttribute("user");
        t.setUid(user.getUid());
        return mapper.insert(t);
    }

    @ApiOperation(value = "跟踪日志")
    @GetMapping
    public List<Tracks> findToday(){
        return mapper.findToday();
    }
}
